package com.googlecode.tapestry5validator.hibernate;

import java.lang.annotation.Annotation;
import java.util.Map;

/**
 * Contains meta-information for creating field validation based on other validation 
 * information(hibernate-validator or jsr-303 annotation or other validation framework information element) 
 * 
 * @author Yesrastov Valentin
 */
public interface ValidatorAdapter {

	/**
	 * String for search in tapestry messages. 
	 */
	String getValidatorType();

	/**
	 * Javascript method name for validation on client side. 
	 * If return null client validation will be disabled.  
	 */
	String getJSMethod();

	/**
	 * Is apply validator for null and empty values. 
	 * Basically, always false. 
	 */
	boolean isRequired();
	
	/**
	 * Hibernate validator annotation class
	 */
	Class<? extends Annotation> getAnnotationClass();

	/**
	 * @param parameters - Map of validator annotation value 
	 * @return - The object which will be handed to a script 
	 */
	Object fetchToJSParametrs(Map<String, Object> parameters);

}
